package org.nicocube.airain.gwt.client.ui.dnd;

import org.nicocube.airain.domain.client.character.Action;
import org.nicocube.airain.domain.client.character.ActionType;

import com.allen_sauer.gwt.dnd.client.HasDragHandle;
import com.google.gwt.user.client.ui.AbsolutePanel;
import com.google.gwt.user.client.ui.FocusPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Widget;

public class CloneableActionWidget extends AbsolutePanel implements HasDragHandle {

	private Widget handle;
	private Action action;
	private ActionType type;
	
	public CloneableActionWidget(ActionType type) {
		this(type,null);
	}
	
	public CloneableActionWidget(ActionType type, Action action) {
		super();
		this.type = type;
		
		addStyleName("airain-action-label");
		setPixelSize(95, 15);
		
		Label l = new Label(type.getLabel());
		l.setWordWrap(false);
		l.setPixelSize(90, 15);
		add(l,5,0);
		handle = new FocusPanel();
		handle.addStyleName("airain-action-handle");
		handle.setPixelSize(3, 20);
		add(handle,0,0);
		this.action = action;
	}
	
	public CloneableActionWidget cloneWidget() {
		return new CloneableActionWidget(type,this.action);
	}

	public Widget getDragHandle() {
		return handle;
	}

	public ActionType getType() {
		return type;
	}

	public void setAction(Action action) {
		this.action = action;
	}

	public Action getAction() {
		return action;
	}
	
}
